# -*- coding:utf-8 -*-
"""
请输入模块注释
"""
__author__ = "shu2015626"

import requests


class YunPian(object):
    """
    使用云片网发送验证码短信
    """
    def __init__(self, apikey):
        self.apikey = apikey
        self.single_send_url = "https://sms.yunpian.com/v2/sms/single_send.json"

    def send_sms(self, mobile, code):
        data = {
            'apikey': self.apikey,
            'mobile': mobile,
            # text的内容必须和云片网上的审核内容一致，否则发送不了
            'text': "【慕学生鲜】您的验证码是{code}.如非本人操作，请忽略本短信".format(code=code)
        }

        response = requests.post(self.single_send_url, data=data)
        res_dct = response.json()
        # print(res_dct)
        return res_dct


if __name__ == "__main__":
    obj_yunpian = YunPian('dsfsd')
    obj_yunpian.send_sms(123456, 15201123456)
